#!/bin/bash

# 下载前端库脚本
# 用于确保所有必要的CSS和JS库都在本地可用

echo "开始下载前端库..."

# 创建目录结构
mkdir -p src/main/resources/static/lib/bootstrap/css
mkdir -p src/main/resources/static/lib/bootstrap/js
mkdir -p src/main/resources/static/lib/bootstrap-icons/font/fonts
mkdir -p src/main/resources/static/lib/npm

# 下载 Bootstrap CSS
echo "下载 Bootstrap CSS..."
curl -L "https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" \
     -o "src/main/resources/static/lib/bootstrap/css/bootstrap.min.css"

# 下载 Bootstrap JavaScript
echo "下载 Bootstrap JavaScript..."
curl -L "https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" \
     -o "src/main/resources/static/lib/bootstrap/js/bootstrap.bundle.min.js"

# 下载 Bootstrap Icons CSS
echo "下载 Bootstrap Icons CSS..."
curl -L "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" \
     -o "src/main/resources/static/lib/bootstrap-icons/font/bootstrap-icons.css"

# 下载 Bootstrap Icons 字体文件
echo "下载 Bootstrap Icons 字体文件..."
curl -L "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/fonts/bootstrap-icons.woff" \
     -o "src/main/resources/static/lib/bootstrap-icons/font/fonts/bootstrap-icons.woff"
curl -L "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/fonts/bootstrap-icons.woff2" \
     -o "src/main/resources/static/lib/bootstrap-icons/font/fonts/bootstrap-icons.woff2"

# 下载 Chart.js
echo "下载 Chart.js..."
curl -L "https://cdn.jsdelivr.net/npm/chart.js" \
     -o "src/main/resources/static/lib/npm/chart.js"

echo "所有前端库下载完成！"
echo ""
echo "下载的文件："
echo "- Bootstrap CSS: src/main/resources/static/lib/bootstrap/css/bootstrap.min.css"
echo "- Bootstrap JS: src/main/resources/static/lib/bootstrap/js/bootstrap.bundle.min.js"
echo "- Bootstrap Icons CSS: src/main/resources/static/lib/bootstrap-icons/font/bootstrap-icons.css"
echo "- Bootstrap Icons Fonts: src/main/resources/static/lib/bootstrap-icons/font/fonts/"
echo "- Chart.js: src/main/resources/static/lib/npm/chart.js" 